# Please install LangChain and OpenAI packages first: `pip install langchain langchain-openai python-dotenv`

import os
import sys

# 添加项目根目录到Python路径，以便导入config_reader模块
current_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(os.path.dirname(current_dir))
sys.path.append(project_root)

from config_reader import get_deepseek_api_key
from langchain_openai import ChatOpenAI
from langchain.schema import HumanMessage, SystemMessage

# 从配置文件获取API密钥
api_key = get_deepseek_api_key()

# 创建ChatOpenAI实例，配置DeepSeek API
llm = ChatOpenAI(
    api_key=api_key,
    base_url="https://api.deepseek.com",
    model="deepseek-chat",
    temperature=0
)

# 创建消息列表
messages = [
    SystemMessage(content="You are a helpful assistant"),
    HumanMessage(content="Hello")
]

# 调用LLM
response = llm.invoke(messages)

# 打印响应
print(response.content)
